#include <fstream>
#include <iostream>
#include <vector>

struct point
{
	double x, y;
    point() {};
	point(double x, double y = 0): x(x), y(y) {};
};

int main() 
{
	size_t n;
	std::cin >> n;
	std::vector<point> points(n);

	for (size_t i = 0; i < n; ++i) 
		std::cin >> points[i].x >> points[i].y;

	int m;
	std::cin >> m;
	std::vector<size_t> ans;
    for (int i = 0; i < m; ++i) 
	{
        double x, y;
		std::cin >> x >> y;
		point a = point(x, y);
        
        std::cin >> x >> y;
		point b = point(x, y);

        //std::cerr << a.x << " " << a.y << " " << b.x << " " << b.y << "\n"; 
		for (size_t j = 0; j < n; ++j) 
			if (a.x <= points[j].x && points[j].x <= b.x &&
                a.y <= points[j].y && points[j].y <= b.y) ans.push_back(j);
        
        std::cout.precision(20);
        std::cout << ans.size() << "\n";
        for (size_t j = 0; j < ans.size(); ++j)
            std::cout << points[ans[j]].x << " " << points[ans[j]].y << "\n";
        ans.clear();
	}
	return 0;
}